package com.wsx.first.c;

import java.util.Scanner;

/**
 * @author: wangshunxi
 * @date: 2022/5/10 16:22
 * @Description:
 */
public class Main0002 {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String content = scanner.nextLine();
            String tag = scanner.nextLine();
            content = content.toUpperCase();
            solution(content, tag.toUpperCase().toCharArray()[0]);
        }
    }

    private static void solution(String content, char tag) {

        if (content == null) {
            System.out.println(-1);
        } else if (content.length() >= 1 && content.length()<=1000) {
            char[] chars = content.toUpperCase().toCharArray();
            int count = 0;
            for (int i = 0; i < chars.length; i++) {
                if (chars[i] == tag) {
                    count++;
                }
            }
            System.out.println(count);
        } else {
            System.out.println(-2);
        }


    }
}
